﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace MvcCmsProjectTracker
{
    public class Routes : AreaRegistration
    {
        public override string AreaName
        {
            get { return "MvcCmsProjectTracker"; }
        }
        public override void RegisterArea(AreaRegistrationContext context)
        {
            var routes = context.Routes;

            routes.MapRoute(
                "Project", // Route name
                "projecttracker/project/{action}/{id}", // URL with parameters
                new { controller = "Project", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            ).DataTokens = new RouteValueDictionary(new { area = AreaName });

            routes.MapRoute(
                "Bug", // Route name
                "projecttracker/bug/{action}/{id}", // URL with parameters
                new { controller = "Bug", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            ).DataTokens = new RouteValueDictionary(new { area = AreaName });

            routes.MapRoute(
                "ProjectBugs", // Route name
                "projecttracker/project/{projectId}/bug/{action}/{id}", // URL with parameters
                new { controller = "Bug", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            ).DataTokens = new RouteValueDictionary(new { area = AreaName });

            routes.MapRoute(
                "Ticket", // Route name
                "projecttracker/ticket/{action}/{id}", // URL with parameters
                new { controller = "Ticket", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            ).DataTokens = new RouteValueDictionary(new { area = AreaName });

            routes.MapRoute(
                "ProjectTickets", // Route name
                "projecttracker/project/{projectId}/ticket/{action}/{id}", // URL with parameters
                new { controller = "Ticket", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            ).DataTokens = new RouteValueDictionary(new { area = AreaName });

        }
    }
}
